<?php 

function searchURL($user, $URL ){

  $con = mysql_connect ("localhost:3306", "root", "fli2411");
  if (!$con) {
    error(DB_ERR);
  }
  mysql_select_db("brain_browser", $con);

//   $URL = str_ireplace("-", "%", $URL);
//   $URL = str_ireplace("*", "%", $URL);


  $result = mysql_query("SELECT link FROM user_link WHERE user='$user' AND link LIKE '%$URL%'", $con);
  if (!$result) {
    error(DB_ERR);
  }
  
  else {
    $i = 0;
    while ($link = mysql_fetch_array($result, MYSQL_NUM) ){
	$arr[$i] = $link;
	$i++;
    }

    if($i > 0){
	$i = 0;
	foreach ($arr as $link){
		$retArr[$i] = $link[0];
		$i++;
	}

	
	return $retArr;
    }
    return -1;
  
  }

}

?>